package com.github.byakkili.bim.core.threadpool;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;

/**
 * @author Guannian Li
 */
public abstract class AbstractThreadPool implements ThreadPool {

    protected final BlockingQueue<Runnable> workQueue(int length) {
        if (length == 0) {
            return new SynchronousQueue<>();
        } else if (length < 0) {
            return new LinkedBlockingQueue<>();
        } else {
            return new LinkedBlockingQueue<>(length);
        }
    }
}
